package com.parking.order.controller;


import com.parking.common.core.model.Result;
import com.parking.common.core.util.JwtUtil;
import com.parking.order.model.dto.findMonthlyIncomeAndHourPlatformDto;
import com.parking.order.service.IPlatformIncomeService;
import com.parking.order.service.IRentersIncomeService;
import com.parking.order.util.BasicInfoUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 吴彦祖
 * @since 2023年11月28日
 */
@RestController
@Api(tags = "平台日月收入统计")
@RequestMapping("/platformIncome")
public class PlatformIncomeController {
    /**
     * 平台日月收入统计服务层
     * */
    @Autowired
    private IPlatformIncomeService platformIncomeService;
    /**
     * 其他模块调用工具类
     * */
    @Autowired
    private BasicInfoUtil basicInfoUtil;
    /**
     * 平台查询12月每日收入
     * 参数 平台token authorization
     * 返回 List<Integer> 1-31日 收入 BigDecimal->int
     * */
    @ApiOperation("平台查询12月每日收入")
    @GetMapping("/findDailyIncome.platform")

    public Result<List<Integer>> findDailyIncomePlatform(@RequestHeader String authorization) throws Exception {
        basicInfoUtil.getPlatform(JwtUtil.getPlatformId(authorization));
        List<Integer> incomes = platformIncomeService.findDailyIncomePlatform();
        return Result.getListResult(Integer.class).setData(incomes).setMessage("平台查询12月每日收入成功");
    }

    /**
     * 平台查询12月出租小时数与总收入
     * 参数 平台token authorization
     * 返回 hour 出租总小时数
     *     income 总收入
     * */
    @ApiOperation("平台查询12月出租小时数与总收入")
    @GetMapping("/findMonthlyIncomeAndHour.platform")
    public Result<findMonthlyIncomeAndHourPlatformDto> findMonthlyIncomeAndHourPlatform(@RequestHeader String authorization) throws Exception {
        basicInfoUtil.getPlatform(JwtUtil.getPlatformId(authorization));
        JwtUtil.parseAdminToken(authorization);
        findMonthlyIncomeAndHourPlatformDto dto = platformIncomeService.findMonthlyIncomeAndHourPlatform();
        return Result.getResult(findMonthlyIncomeAndHourPlatformDto.class).setData(dto).setMessage("平台查询12月出租小时数与总收入");
    }
}

